package com.controller;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.DeliverCallback;
import com.util.RabbitmqUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/consumer")
public class Consumer {

    private String message = "";

    @RequestMapping("/receive")
    public String receive() {
        DeliverCallback deliverCallback = (consumerTag, delivery) -> {
            message = new String(delivery.getBody(), "UTF-8");
            System.out.println("消费者接收到队列的消息：" + message);
        };
        // 消费队列
        RabbitmqUtils.receive("woniu12", false, false, false, null, deliverCallback);
        return "完成消费111";
    }
}
